package com.txunda.zhuohired.adapter.user.home;

import android.content.Context;
import android.graphics.Color;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.txunda.zhuohired.R;
import com.txunda.zhuohired.bean.user.resume.ExpectBean;

import java.util.ArrayList;

/**
 * Created by admin on 2018/3/2.
 */

public class ExpectJobSelectAdapter extends BaseAdapter {

    ArrayList<ExpectBean.DataBean> data;
    Context context;
    ViewHolder holder;
    private int select_position = 0;

    public ExpectJobSelectAdapter(Context context, ArrayList<ExpectBean.DataBean> data) {
        this.data = data;
        this.context = context;
    }

    @Override
    public int getCount() {
        return data.size();
    }

    @Override
    public Object getItem(int i) {
        return data.get(i);
    }

    @Override
    public long getItemId(int i) {
        return i;
    }

    @Override
    public View getView(int i, View view, ViewGroup viewGroup) {
        if (view == null) {
            view = LayoutInflater.from(context).inflate(R.layout.item_expect_job, null);
            holder = new ViewHolder();
            holder.tv_item_expect_job = view.findViewById(R.id.tv_item_expect_job);
            holder.ll_item_expect_job = view.findViewById(R.id.ll_item_expect_job);
            view.setTag(holder);
        } else {
            holder = (ViewHolder) view.getTag();
        }
        holder.tv_item_expect_job.setText(data.get(i).getName());
        if (select_position == i) {
            holder.tv_item_expect_job.setTextColor(context.getResources().getColor(R.color.blue));
            holder.ll_item_expect_job.setBackgroundColor(Color.rgb(250, 250, 250));
        } else {
            holder.tv_item_expect_job.setTextColor(context.getResources().getColor(R.color.home_grey3));
            holder.ll_item_expect_job.setBackgroundColor(Color.WHITE);
        }

        return view;
    }

    public void setSelectPosition(int position) {
        select_position = position;
        notifyDataSetChanged();
    }

    class ViewHolder {
        TextView tv_item_expect_job;
        LinearLayout ll_item_expect_job;
    }
}
